package LeetCode热题HOT100;

public class p75颜色分类 {
    public void sortColors1(int[] nums) {
        //直接选择排序
        for (int i = 0; i <nums.length; i++) {
            for (int j = i+1; j <nums.length; j++) {
                if (nums[i]>nums[j]) {
                    int tmp=nums[i];
                    nums[i]=nums[j];
                    nums[j]=tmp;
                }
            }
        }
    }

    public void sortColors(int[] nums) {
        //冒泡排序
        for (int i = 0; i <nums.length; i++) {
            for (int j = 0; j <nums.length-1; j++) {
                if (nums[j]>nums[j+1]) {
                    int tmp=nums[j];
                    nums[j]=nums[j+1];
                    nums[j+1]=tmp;
                }
            }
        }
    }
}
